package com.model.xmlElement.output;

import java.io.Serializable;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * *********************************************
 * @author Administrator
 * @FileName OutputFileHdfs.java
 * @DescriptionaXML配置之hdfs配置
 **********************************************
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class OutputFileHdfs implements Serializable{
	public static final Logger LOG = LoggerFactory.getLogger(OutputFileHdfs.class);
	private static final long serialVersionUID = 1L;
	
	@XmlElement(name = "output_hdfs_file_dir")
	private String outputHdfsFileDir;						//hdfs->输出文件夹
	
	@XmlElement(name = "output_hdfs_file_name")
	private String outputHdfsFileName;						//hdfs->输出文件名字
	
	@XmlElement(name = "output_hdfs_file_ext")
	private String outputHdfsFileExt;						//hdfs->输出文件后缀
	
	@XmlElement(name = "output_hdfs_file_encoding")
	private String outputHdfsFileEncoding;					//hdfs->输出文件编码

	public void setOutputHdfsFileDir(String outputHdfsFileDir) {
		this.outputHdfsFileDir = outputHdfsFileDir;
	}

	public void setOutputHdfsFileName(String outputHdfsFileName) {
		this.outputHdfsFileName = outputHdfsFileName;
	}

	public void setOutputHdfsFileExt(String outputHdfsFileExt) {
		this.outputHdfsFileExt = outputHdfsFileExt;
	}

	public void setOutputHdfsFileEncoding(String outputHdfsFileEncoding) {
		this.outputHdfsFileEncoding = outputHdfsFileEncoding;
	}

	public OutputFileHdfs() {
		super();
	}
	
	public String getOutputHdfsFileName1(){
		return outputHdfsFileName;
	}
	
	/**
	 * 文件名加后缀"_1"
	 * @return
	 */
	public String getOutputHdfsFileName() {
		return outputHdfsFileName + "_1";
	}
	/**
	 * 完整hdfsDir
	 * @return
	 */
	public String getOutputHdfsFileDir(String taskId,String taskTime,String taskSource) {
		StringBuilder stringBuilder = new StringBuilder(100);
		if(outputHdfsFileDir.charAt(outputHdfsFileDir.length() - 1) != '/'){
			stringBuilder.append(outputHdfsFileDir).append("/").append(taskId).append("_").append(taskTime).append("_").append(taskSource).append("/");
		}else{
			stringBuilder.append(outputHdfsFileDir).append(taskId).append("_").append(taskTime).append("_").append(taskSource).append("/");
		}
		return stringBuilder.toString();
	}
	/**
	 * 完整文件名
	 * @param uuid
	 * @param user
	 * @param dateString
	 * @return
	 */
	public String getOutputHdfsFilePath(String taskId,String user,String taskTime,String taskSource){
		StringBuilder stringBuilder = new StringBuilder(200);
		stringBuilder.append(getOutputHdfsFileDir(taskId,taskTime,taskSource)).append("task_").append(taskId).append("_").append(user).append("_").append(taskTime).append("_").append(getOutputHdfsFileName()).append(".").append(outputHdfsFileExt);
		return stringBuilder.toString();
	}
	/**
	 * 文件默认后缀
	 * @return
	 */
	public String getOutputHdfsFileExt() {
		return (outputHdfsFileExt == null || outputHdfsFileExt.equals("")) ? "csv" : outputHdfsFileExt;
	}
	/**
	 * 文件默认编码
	 * @return
	 */
	public String getOutputHdfsFileEncoding() {
		return (outputHdfsFileEncoding == null || outputHdfsFileEncoding.equals("")) ? "UTF-8" : outputHdfsFileEncoding;
	}

	
}
